home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Chans / x40088 / x400outext.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  35.3 KB  |  1,383 lines

  1. /* x400outext.c: extension attributes for X400out88 */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Chans/x40088/RCS/x400outext.c,v 6.0 1991/12/18 20:14:27 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Chans/x40088/RCS/x400outext.c,v 6.0 1991/12/18 20:14:27 jpo Rel $
  9.  *
  10.  * $Log: x400outext.c,v $
  11.  * Revision 6.0  1991/12/18  20:14:27  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "Trans-types.h"
  19. #include "Ext-types.h"
  20. #include "util.h"
  21. #include "q.h"
  22. #include "adr.h"
  23. #include "dr.h"
  24. #include "or.h"
  25. #include <isode/cmd_srch.h>
  26. #include <rtsparams.h>
  27.  
  28. struct type_UNIV_UTCTime *build_time ();
  29. struct type_MTA_ORName *build_fullname ();
  30. struct type_MTA_ORName    *build_addr ();
  31. struct type_MTA_GlobalDomainIdentifier *build_gdi ();
  32. extern int trace_type;
  33.  
  34. #define wrap_up_ext(e, n)    \
  35.     (e) = (struct type_MTA_Extensions *) smalloc (sizeof *extl); \
  36.     (e) -> next = NULL; (e) -> ExtensionField = (n);
  37. #define STR2QB(s)    str2qb(s, strlen(s), 1)
  38.  
  39.  
  40. static struct type_MTA_ExtensionType *build_ext_type (ext_int, ext_oid)
  41. int    ext_int;
  42. OID    ext_oid;
  43. {
  44.     struct type_MTA_ExtensionType *type;
  45.  
  46.     type = (struct type_MTA_ExtensionType *) smalloc (sizeof *type);
  47.  
  48.     if (ext_int == EXT_OID_FORM) {
  49.         type -> offset = type_MTA_ExtensionType_local;
  50.         type -> un.local = oid_cpy (ext_oid);
  51.     } else {
  52.         type -> offset = type_MTA_ExtensionType_global;
  53.         type -> un.global = ext_int;
  54.     }
  55.     return type;
  56. }
  57.  
  58. static struct type_MTA_Criticality *build_crit (cr)
  59. int    cr;
  60. {
  61.     char    *p;
  62.  
  63.     p = int2strb (cr, 3);
  64.     return strb2bitstr (p, 3, PE_CLASS_UNIV, PE_PRIM_BITS);
  65. }
  66.  
  67. static PE    build_ext_value (qb)
  68. struct qbuf *qb;
  69. {
  70.     char    *cp;
  71.     PS    ps;
  72.     PE    pe;
  73.  
  74.     cp = qb2str(qb);
  75.  
  76.     if ((ps = ps_alloc (str_open)) == NULLPS)
  77.         adios (NULLCP, "PS alloc failed");
  78.  
  79.     if (str_setup (ps, cp, qb -> qb_len, 1) == NOTOK)
  80.         adios (NULLCP, "Can't setup PS stream");
  81.  
  82.     if ((pe = ps2pe (ps)) == NULLPE)
  83.         adios (NULLCP, "ps2pe failed [%s]",
  84.                ps_error (ps -> ps_errno));
  85.     ps_free (ps);
  86.     return pe;
  87. }    
  88.  
  89. static struct type_MTA_Extensions *build_ext_rrp (parm, crit)
  90. int    parm;
  91. char    crit;
  92. {
  93.     struct type_MTA_ExtensionField *ext;
  94.     struct type_Ext_RecipientReassignmentProhibited *value;
  95.     struct type_MTA_Extensions *extl;
  96.  
  97.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  98.  
  99.     ext -> type = build_ext_type (EXT_RECIPIENT_REASSIGNMENT_PROHIBITED,
  100.                       NULLOID);
  101.  
  102.     if (crit != EXT_RECIPIENT_REASSIGNMENT_PROHIBITED_DC)
  103.         ext -> criticality = build_crit (crit);
  104.     else ext -> criticality = NULL;
  105.  
  106.     value = (struct type_Ext_RecipientReassignmentProhibited *)
  107.         smalloc (sizeof *value);
  108.     value -> parm = parm;
  109.     if (encode_Ext_RecipientReassignmentProhibited
  110.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  111.         adios (NULLCP, "Can't encode RecipientReassignmentProhibited value [%s]", PY_pepy);
  112.  
  113.     PP_PDUP (Ext_RecipientReassignmentProhibited,
  114.         ext -> value, "Extensions.RecipientReassignmentProhibited",
  115.         PDU_WRITE);
  116.  
  117.     free_Ext_RecipientReassignmentProhibited (value);
  118.  
  119.     wrap_up_ext (extl, ext);
  120.     return extl;
  121. }
  122.  
  123. static struct type_MTA_Extensions *build_ext_dep (parm, crit)
  124. int    parm;
  125. char    crit;
  126. {
  127.     struct type_MTA_ExtensionField *ext;
  128.     struct type_Ext_DLExpansionProhibited *value;
  129.     struct type_MTA_Extensions *extl;
  130.  
  131.     
  132.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  133.  
  134.     ext -> type = build_ext_type (EXT_DL_EXPANSION_PROHIBITED,
  135.                       NULLOID);
  136.  
  137.     if (crit != EXT_DL_EXPANSION_PROHIBITED_DC)
  138.         ext -> criticality = build_crit (crit);
  139.     else
  140.         ext -> criticality = NULL;
  141.  
  142.     value = (struct type_Ext_DLExpansionProhibited *)
  143.         smalloc (sizeof *value);
  144.     value -> parm = parm;
  145.     if (encode_Ext_DLExpansionProhibited
  146.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  147.         adios (NULLCP, "Can't encode DLExpansionProhibited value [%s]", PY_pepy);
  148.  
  149.     PP_PDUP (Ext_DLExpansionProhibited,
  150.         ext -> value, "Extensions.DLExpansionProhibited",
  151.         PDU_WRITE);
  152.  
  153.     free_Ext_DLExpansionProhibited (value);
  154.  
  155.     wrap_up_ext (extl, ext);
  156.     return extl;
  157. }
  158.  
  159. static struct type_MTA_Extensions *build_ext_cwlp (parm, crit)
  160. int    parm;
  161. char    crit;
  162. {
  163.     struct type_MTA_ExtensionField *ext;
  164.     struct type_Ext_ConversionWithLossProhibited *value;
  165.     struct type_MTA_Extensions *extl;
  166.     
  167.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  168.  
  169.     ext -> type = build_ext_type (EXT_CONVERSION_WITH_LOSS_PROHIBITED,
  170.                       NULLOID);
  171.  
  172.     if (crit != EXT_CONVERSION_WITH_LOSS_PROHIBITED_DC)
  173.         ext -> criticality = build_crit (crit);
  174.     else
  175.         ext -> criticality = NULL;
  176.  
  177.     value = (struct type_Ext_ConversionWithLossProhibited *)
  178.         smalloc (sizeof *value);
  179.     value -> parm = parm;
  180.     if (encode_Ext_ConversionWithLossProhibited
  181.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  182.         adios (NULLCP, "Can't encode ConversionWithLossProhibited value [%s]", PY_pepy);
  183.  
  184.     PP_PDUP (Ext_ConversionWithLossProhibited,
  185.         ext -> value, "Extensions.ConversionWithLossProhibited",
  186.         PDU_WRITE);
  187.  
  188.     free_Ext_ConversionWithLossProhibited (value);
  189.  
  190.     wrap_up_ext (extl, ext);
  191.     return extl;
  192. }
  193.  
  194. static struct type_MTA_Extensions *build_ext_lt (parm, crit)
  195. UTC    parm;
  196. char    crit;
  197. {
  198.     struct type_MTA_ExtensionField *ext;
  199.     struct type_Ext_LatestDeliveryTime *value;
  200.     struct type_MTA_Extensions *extl;
  201.  
  202.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  203.  
  204.     ext -> type = build_ext_type (EXT_LATEST_DELIVERY_TIME,
  205.                       NULLOID);
  206.  
  207.     if (crit != EXT_LATEST_DELIVERY_TIME_DC)
  208.         ext -> criticality = build_crit (crit);
  209.     else
  210.         ext -> criticality = NULL;
  211.  
  212.     value  = build_time (parm);
  213.  
  214.     if (encode_Ext_LatestDeliveryTime
  215.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  216.         adios (NULLCP, "Can't encode LatestDeliveryTime value [%s]", PY_pepy);
  217.  
  218.     PP_PDUP (Ext_LatestDeliveryTime,
  219.         ext -> value, "Extensions.LatestDeliveryTime",
  220.         PDU_WRITE);
  221.  
  222. /*    free_Ext_LatestDeliveryTime (value); too early */
  223.  
  224.     wrap_up_ext (extl, ext);
  225.     return extl;
  226. }
  227.  
  228. static struct type_MTA_Extensions *build_ext_ora (parm, crit)
  229. FullName    *parm;
  230. char    crit;
  231. {
  232.     struct type_MTA_ExtensionField *ext;
  233.     struct type_Ext_OriginatorReturnAddress *value;
  234.     struct type_MTA_ORName *orn;
  235.     struct type_MTA_Extensions *extl;
  236.  
  237.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  238.  
  239.     ext -> type = build_ext_type (EXT_ORIGINATOR_RETURN_ADDRESS,
  240.                       NULLOID);
  241.  
  242.     if (crit != EXT_ORIGINATOR_RETURN_ADDRESS_DC)
  243.         ext -> criticality = build_crit (crit);
  244.     else
  245.         ext -> criticality = NULL;
  246.  
  247.     
  248.     orn = build_addr (parm -> fn_addr);
  249.     value = (struct type_Ext_OriginatorReturnAddress *)
  250.         smalloc (sizeof *value);
  251.     value -> standard__attributes = orn -> standard__attributes;
  252.     orn -> standard__attributes = NULL;
  253.     value -> domain__defined__attributes = orn -> domain__defined;
  254.     orn -> domain__defined = NULL;
  255.     value -> extension__attributes = orn -> extension__attributes;
  256.     orn -> extension__attributes = NULL;
  257.     free_MTA_ORName (orn);
  258.  
  259.     if (encode_Ext_OriginatorReturnAddress
  260.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  261.         adios (NULLCP, "Can't encode OriginatorReturnAddress value [%s]", PY_pepy);
  262.  
  263.     PP_PDUP (Ext_OriginatorReturnAddress,
  264.         ext -> value, "Extensions.OriginatorReturnAddress",
  265.         PDU_WRITE);
  266.  
  267. /*    free_Ext_OriginatorReturnAddress (value); too early */
  268.  
  269.     wrap_up_ext (extl, ext);
  270.     return extl;
  271. }
  272.  
  273. static struct type_MTA_Extensions *build_ext_oc (parm, crit)
  274. struct qbuf    *parm;
  275. char    crit;
  276. {
  277.     struct type_MTA_ExtensionField *ext;
  278.     struct type_MTA_Extensions *extl;
  279.  
  280.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  281.  
  282.     ext -> type = build_ext_type (EXT_ORIGINATOR_CERTIFICATE,
  283.                       NULLOID);
  284.  
  285.     if (crit != EXT_ORIGINATOR_CERTIFICATE_DC)
  286.         ext -> criticality = build_crit (crit);
  287.     else
  288.         ext -> criticality = NULL;
  289.  
  290.     
  291.     ext -> value = build_ext_value (parm);
  292.  
  293.     PP_PDUP (Ext_OriginatorCertificate,
  294.         ext -> value, "Extensions.OriginatorCertificate",
  295.         PDU_WRITE);
  296.  
  297.     wrap_up_ext (extl, ext);
  298.     return extl;
  299. }
  300.  
  301. static struct type_MTA_Extensions *build_ext_ai (parm, crit)
  302. struct qbuf    *parm;
  303. char    crit;
  304. {
  305.     struct type_MTA_ExtensionField *ext;
  306.     struct type_MTA_Extensions *extl;
  307.  
  308.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  309.  
  310.     ext -> type = build_ext_type (EXT_CONTENT_CONFIDENTIALITY_ALGORITHM_IDENTIFIER,
  311.                       NULLOID);
  312.  
  313.     if (crit != EXT_CONTENT_CONFIDENTIALITY_ALGORITHM_IDENTIFIER_DC)
  314.         ext -> criticality = build_crit (crit);
  315.     else
  316.         ext -> criticality = NULL;
  317.  
  318.     
  319.     ext -> value = build_ext_value (parm);
  320.  
  321.     PP_PDUP (Ext_ContentConfidentialityAlgorithmIdentifier,
  322.         ext -> value, "Extensions.ContentConfidentialityAlgorithmIdentifier",
  323.         PDU_WRITE);
  324.  
  325.     wrap_up_ext (extl, ext);
  326.     return extl;
  327. }
  328.  
  329. static struct type_MTA_Extensions *build_ext_moac (parm, crit)
  330. struct qbuf    *parm;
  331. char    crit;
  332. {
  333.     struct type_MTA_ExtensionField *ext;
  334.     struct type_MTA_Extensions *extl;
  335.  
  336.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  337.  
  338.     ext -> type = build_ext_type (EXT_MESSAGE_ORIGIN_AUTHENTICATION_CHECK,
  339.                       NULLOID);
  340.  
  341.     if (crit != EXT_MESSAGE_ORIGIN_AUTHENTICATION_CHECK_DC)
  342.         ext -> criticality = build_crit (crit);
  343.     else
  344.         ext -> criticality = NULL;
  345.  
  346.     
  347.     ext -> value = build_ext_value (parm);
  348.  
  349.     PP_PDUP (Ext_MessageOriginAuthenticationCheck,
  350.         ext -> value, "Extensions.MessageOriginAuthenticationCheck",
  351.         PDU_WRITE);
  352.  
  353.     wrap_up_ext (extl, ext);
  354.     return extl;
  355. }
  356.  
  357. static struct type_MTA_Extensions *build_ext_poac (parm, crit)
  358. struct qbuf    *parm;
  359. char    crit;
  360. {
  361.     struct type_MTA_ExtensionField *ext;
  362.     struct type_MTA_Extensions *extl;
  363.  
  364.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  365.  
  366.     ext -> type = build_ext_type (EXT_PROBE_ORIGIN_AUTHENTICATION_CHECK,
  367.                       NULLOID);
  368.  
  369.     if (crit != EXT_PROBE_ORIGIN_AUTHENTICATION_CHECK_DC)
  370.         ext -> criticality = build_crit (crit);
  371.     else
  372.         ext -> criticality = NULL;
  373.  
  374.     
  375.     ext -> value = build_ext_value (parm);
  376.  
  377.     PP_PDUP (Ext_ProbeOriginAuthenticationCheck,
  378.         ext -> value, "Extensions.ProbeOriginAuthenticationCheck",
  379.         PDU_WRITE);
  380.  
  381.     wrap_up_ext (extl, ext);
  382.     return extl;
  383. }
  384.  
  385.  
  386. static struct type_MTA_Extensions *build_ext_sl (parm, crit)
  387. struct qbuf    *parm;
  388. char    crit;
  389. {
  390.     struct type_MTA_ExtensionField *ext;
  391.     struct type_MTA_Extensions *extl;
  392.  
  393.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  394.  
  395.     ext -> type = build_ext_type (EXT_MESSAGE_SECURITY_LABEL,
  396.                       NULLOID);
  397.  
  398.     if (crit != EXT_MESSAGE_SECURITY_LABEL_DC)
  399.         ext -> criticality = build_crit (crit);
  400.     else
  401.         ext -> criticality = NULL;
  402.  
  403.     
  404.     ext -> value = build_ext_value (parm);
  405.  
  406.     PP_PDUP (Ext_MessageSecurityLabel,
  407.         ext -> value, "Extensions.MessageSecurityLabel",
  408.         PDU_WRITE);
  409.  
  410.     wrap_up_ext (extl, ext);
  411.     return extl;
  412. }
  413.  
  414. static struct type_MTA_Extensions *build_ext_cc (parm, crit)
  415. struct qbuf    *parm;
  416. char    crit;
  417. {
  418.     struct type_MTA_ExtensionField *ext;
  419.     struct type_MTA_Extensions *extl;
  420.  
  421.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  422.  
  423.     ext -> type = build_ext_type (EXT_CONTENT_CORRELATOR,
  424.                       NULLOID);
  425.  
  426.     if (crit != EXT_CONTENT_CORRELATOR_DC)
  427.         ext -> criticality = build_crit (crit);
  428.     else
  429.         ext -> criticality = NULL;
  430.  
  431.     
  432.     ext -> value = build_ext_value (parm);
  433.  
  434.     PP_PDUP (Ext_ContentCorrelator,
  435.         ext -> value, "Extensions.ContentCorrelator",
  436.         PDU_WRITE);
  437.  
  438.     wrap_up_ext (extl, ext);
  439.     return extl;
  440. }
  441.  
  442. static struct type_Ext_DLExpansionHistory * build_dehl (dlh)
  443. DLHistory *dlh;
  444. {
  445.     struct type_Ext_DLExpansionHistory *dlist = NULL, **dp;
  446.     struct type_Ext_DLExpansion *d;
  447.  
  448.     dp = &dlist;
  449.     for (;dlh; dlh = dlh -> dlh_next) {
  450.         *dp = (struct type_Ext_DLExpansionHistory *)
  451.             smalloc (sizeof **dp);
  452.         (*dp) -> next = NULL;
  453.         d = (*dp) -> DLExpansion =
  454.             (struct type_Ext_DLExpansion *)
  455.                 smalloc (sizeof *d);
  456.         d -> address = build_addr (dlh -> dlh_addr);
  457.         d -> dl__expansion__time = build_time (dlh -> dlh_time);
  458.         dp = &(*dp) -> next;
  459.     }
  460.     return dlist;
  461. }
  462.     
  463. static struct type_MTA_Extensions *build_ext_dl (parm, crit)
  464. DLHistory *parm;
  465. char    crit;
  466. {
  467.     struct type_MTA_ExtensionField *ext;
  468.     struct type_Ext_DLExpansionHistory *value;
  469.     struct type_MTA_Extensions *extl;
  470.  
  471.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  472.  
  473.     ext -> type = build_ext_type (EXT_DL_EXPANSION_HISTORY,
  474.                       NULLOID);
  475.  
  476.     if (crit != EXT_DL_EXPANSION_HISTORY_DC)
  477.         ext -> criticality = build_crit (crit);
  478.     else
  479.         ext -> criticality = NULL;
  480.  
  481.     value = build_dehl (parm);
  482.  
  483.     if (encode_Ext_DLExpansionHistory
  484.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  485.         adios (NULLCP, "Can't encode DLExpansionHistory value [%s]", PY_pepy);
  486.  
  487.     PP_PDUP (Ext_DLExpansionHistory,
  488.         ext -> value, "Extensions.DLExpansionHistory",
  489.         PDU_WRITE);
  490.  
  491.     free_Ext_DLExpansionHistory (value);
  492.  
  493.     wrap_up_ext (extl, ext);
  494.     return extl;
  495. }
  496.  
  497. static struct type_Ext_MTASuppliedInformation * build_msi (dp)
  498. DomSupInfo *dp;
  499. {
  500.     struct type_Ext_MTASuppliedInformation *msi;
  501.  
  502.     msi = (struct type_Ext_MTASuppliedInformation *)
  503.         calloc (1, sizeof *msi);
  504.     if (dp -> dsi_time)
  505.         msi -> arrival__time = build_time (dp -> dsi_time);
  506.     msi -> routing__action = (struct type_MTA_RoutingAction *)
  507.         smalloc (sizeof *msi -> routing__action);
  508.     msi -> routing__action -> parm = dp -> dsi_action;
  509.  
  510.     if (dp -> dsi_attempted_mta ||
  511.         (dp -> dsi_attempted_md.global_Country &&
  512.          dp -> dsi_attempted_md.global_Admin)) {
  513.         msi -> attempted = (struct choice_Ext_1 *)
  514.             calloc (1, sizeof *msi -> attempted);
  515.         if (dp -> dsi_attempted_mta) {
  516.             msi -> attempted -> offset =
  517.                 choice_Ext_1_mta;
  518.             msi -> attempted -> un.mta =
  519.                 STR2QB (dp -> dsi_attempted_mta);
  520.         }
  521.         else {
  522.             msi -> attempted -> offset =
  523.                 choice_Ext_1_domain;
  524.             msi -> attempted -> un.domain =
  525.                 build_gdi (&dp -> dsi_attempted_md);
  526.         }
  527.     }
  528.  
  529.     if (dp -> dsi_deferred)
  530.         msi -> deferred__time = build_time (dp -> dsi_deferred);
  531.     if (dp -> dsi_other_actions) {
  532.         msi -> other__actions =
  533.             pe_alloc (PE_CLASS_UNIV, PE_FORM_PRIM,
  534.                       PE_PRIM_BITS);
  535.             if (dp -> dsi_other_actions & ACTION_REDIRECTED)
  536.                 bit_on (msi -> other__actions,
  537.                     bit_MTA_OtherActions_redirected);
  538.             if (dp -> dsi_other_actions & ACTION_EXPANDED)
  539.                 bit_on (msi -> other__actions,
  540.                     bit_MTA_OtherActions_dl__operation);
  541.     }
  542.     return msi;
  543. }
  544.  
  545.  
  546. static struct type_Ext_InternalTraceInformation *build_inttrace (tp)
  547. Trace    *tp;
  548. {
  549.     struct type_Ext_InternalTraceInformation *tlist = NULL, **tpp;
  550.     struct type_Ext_InternalTraceInformationElement *ti;
  551.     Trace    *tlast;
  552.  
  553.     if (trace_type == RTSP_TRACE_ADMD ||
  554.         trace_type == RTSP_TRACE_NOINT)
  555.         return NULL;
  556.  
  557.     for (tlast = tp; tlast && tlast -> trace_next;
  558.          tlast = tlast -> trace_next)
  559.         continue;
  560.  
  561.     tpp = &tlist;
  562.     for (; tp; tp = tp -> trace_next) {
  563.         if (tp -> trace_mta == NULLCP)
  564.             continue;
  565.         if (trace_type == RTSP_TRACE_LOCALINT &&
  566.             !same_prmd (tlast, tp))
  567.             continue;
  568.         *tpp = (struct type_Ext_InternalTraceInformation *)
  569.             smalloc (sizeof **tpp);
  570.         (*tpp) -> next = NULL;
  571.         ti = (*tpp) -> InternalTraceInformationElement =
  572.             (struct type_Ext_InternalTraceInformationElement *)
  573.                 calloc (1, sizeof *ti);
  574.         ti -> global__domain__identifier =
  575.             build_gdi (&tp -> trace_DomId);
  576.         ti -> mta__name = STR2QB (tp -> trace_mta);
  577.  
  578.         ti -> mta__supplied__information =
  579.             build_msi (&tp -> trace_DomSinfo);
  580.         tpp = &(*tpp) -> next;
  581.     }
  582.     return tlist;
  583. }
  584.  
  585. static struct type_MTA_Extensions *build_ext_iti (parm, crit)
  586. Trace    *parm;
  587. char    crit;
  588. {
  589.     struct type_MTA_ExtensionField *ext;
  590.     struct type_Ext_InternalTraceInformation *value;
  591.     struct type_MTA_Extensions *extl;
  592.     PE    pe;
  593.  
  594.     value = build_inttrace (parm);
  595.     if (value == NULL)
  596.         return NULL;
  597.  
  598.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  599.  
  600.     ext -> type = build_ext_type (EXT_INTERNAL_TRACE_INFORMATION,
  601.                       NULLOID);
  602.  
  603.     if (crit != EXT_INTERNAL_TRACE_INFORMATION_DC)
  604.         ext -> criticality = build_crit (crit);
  605.     else
  606.         ext -> criticality = NULL;
  607.  
  608.  
  609.     if (encode_Ext_InternalTraceInformation
  610.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  611.         adios (NULLCP, "Can't encode InternalTraceInformation value [%s]", PY_pepy);
  612.  
  613.     PP_PDUP (Ext_InternalTraceInformation,
  614.         ext -> value, "Extensions.InternalTraceInformation",
  615.         PDU_WRITE);
  616.     pe = pe_cpy (ext->value);
  617.     pe_free (ext->value);
  618.     ext -> value = pe;
  619.  
  620.     free_Ext_InternalTraceInformation (value);
  621.  
  622.     wrap_up_ext (extl, ext);
  623.     return extl;
  624. }
  625.  
  626.  
  627. static struct type_MTA_Extensions *build_ext_posr (parm, crit)
  628. int    parm;
  629. char    crit;
  630. {
  631.     struct type_MTA_ExtensionField *ext;
  632.     struct type_MTA_Extensions *extl;
  633.     struct type_Ext_ProofOfSubmissionRequest *value;
  634.  
  635.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  636.  
  637.     ext -> type = build_ext_type (EXT_PROOF_OF_SUBMISSION_REQUEST, NULLOID);
  638.  
  639.     ext -> criticality = build_crit (crit);
  640.  
  641.     value = (struct type_Ext_ProofOfSubmissionRequest *)
  642.         smalloc (sizeof *value);
  643.     value -> parm = parm;
  644.  
  645.     if (encode_Ext_ProofOfSubmissionRequest
  646.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  647.         adios (NULLCP, "Can't encode ProofOfSubmissionRequest value [%s]",
  648.                PY_pepy);
  649.     PP_PDUP (Ext_ProofOfSubmissionRequest,
  650.         ext -> value, "Extensions.ProofOfSubmissionRequest",
  651.         PDU_WRITE);
  652.  
  653.     free_Ext_ProofOfSubmissionRequest (value);
  654.  
  655.     wrap_up_ext (extl, ext);
  656.     return extl;
  657. }
  658.  
  659. static struct type_MTA_Extensions *build_ext_forw_req (parm, crit)
  660. int    parm;
  661. char    crit;
  662. {
  663.     struct type_MTA_ExtensionField *ext;
  664.     struct type_MTA_Extensions *extl;
  665.     struct type_Ext_SequenceNumber *value;
  666.  
  667.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  668.  
  669.     ext -> type = build_ext_type (EXT_FORWARDING_REQUEST, NULLOID);
  670.  
  671.     ext -> criticality = build_crit (crit);
  672.  
  673.     value = (struct type_Ext_SequenceNumber *)
  674.         smalloc (sizeof *value);
  675.     value -> parm = parm;
  676.  
  677.     if (encode_Ext_SequenceNumber
  678.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  679.         adios (NULLCP, "Can't encode forwarding request value [%s]",
  680.                PY_pepy);
  681.     PP_PDUP (Ext_SequenceNumber,
  682.         ext -> value, "Extensions.SequenceNumber",
  683.         PDU_WRITE);
  684.  
  685.     free_Ext_SequenceNumber (value);
  686.  
  687.     wrap_up_ext (extl, ext);
  688.     return extl;
  689. }
  690.  
  691.  
  692. static struct type_MTA_ExtensionField *build_extension (ext)
  693. X400_Extension *ext;
  694. {
  695.     struct type_MTA_ExtensionField *ep;
  696.  
  697.     ep = (struct type_MTA_ExtensionField *) smalloc (sizeof *ep);
  698.     ep -> type = build_ext_type (ext -> ext_int, ext -> ext_oid);
  699.     ep -> criticality = build_crit (ext -> ext_criticality);
  700.     ep -> value = build_ext_value (ext -> ext_value);
  701.     return ep;
  702. }
  703.  
  704. struct type_MTA_Extensions *build_pm_extensions (qp,p1,msg)
  705. Q_struct *qp;
  706. int p1,msg;
  707. {
  708.     struct type_MTA_Extensions *ext = NULL, **ep;
  709.     X400_Extension *pp_exp;
  710.  
  711.     ep = &ext;
  712.     for (pp_exp = qp -> per_message_extensions; pp_exp; pp_exp = pp_exp -> ext_next) {
  713.         *ep = (struct type_MTA_Extensions *)
  714.                 smalloc (sizeof *ep);
  715.         (*ep) -> next = NULL;
  716.         (*ep) -> ExtensionField = build_extension (pp_exp);
  717.         ep = &(*ep) -> next;
  718.     }
  719.     if (qp -> recip_reassign_prohibited) {
  720.         *ep = build_ext_rrp (qp -> recip_reassign_prohibited,
  721.                      qp -> recip_reassign_crit);
  722.         if (*ep)
  723.             ep = &(*ep) -> next;
  724.     }
  725.     if (qp -> dl_expansion_prohibited) {
  726.         *ep = build_ext_dep (qp -> dl_expansion_prohibited,
  727.                      qp -> dl_expansion_crit);
  728.         if (*ep)
  729.             ep = &(*ep) -> next;
  730.     }
  731.     if (qp -> conversion_with_loss_prohibited) {
  732.         *ep = build_ext_cwlp (qp -> conversion_with_loss_prohibited,
  733.                       qp -> conversion_with_loss_crit);
  734.         if (*ep)
  735.             ep = &(*ep) -> next;
  736.     }
  737.     if (qp -> originator_certificate) {
  738.         *ep = build_ext_oc (qp -> originator_certificate,
  739.                     qp -> originator_certificate_crit);
  740.         if (*ep)
  741.             ep = &(*ep) -> next;
  742.     }
  743.     if (qp -> security_label) {
  744.         *ep = build_ext_sl (qp -> security_label,
  745.                     qp -> security_label_crit);
  746.         if (*ep)
  747.             ep = &(*ep) -> next;
  748.     }
  749.     if (qp -> general_content_correlator) {
  750.         *ep = build_ext_cc (qp -> general_content_correlator,
  751.                     qp -> content_correlator_crit);
  752.         if (*ep)
  753.             ep = &(*ep) -> next;
  754.     }
  755.     if (msg) {
  756.         if (qp -> latest_time) {
  757.             *ep = build_ext_lt (qp -> latest_time,
  758.                         qp -> latest_time_crit);
  759.             if (*ep)
  760.                 ep = &(*ep) -> next;
  761.         }
  762.         if (qp -> originator_return_address) {
  763.             *ep = build_ext_ora (qp -> originator_return_address,
  764.                          qp -> originator_return_address_crit);
  765.             if (*ep)
  766.                 ep = &(*ep) -> next;
  767.         }
  768.         if (qp -> algorithm_identifier) {
  769.             *ep = build_ext_ai (qp -> algorithm_identifier,
  770.                         qp -> algorithm_identifier_crit);
  771.             if (*ep)
  772.                 ep = &(*ep) -> next;
  773.         }
  774.         if (qp -> message_origin_auth_check) {
  775.             *ep = build_ext_moac (qp -> message_origin_auth_check,
  776.                           qp -> message_origin_auth_check_crit);
  777.             if (*ep)
  778.                 ep = &(*ep) -> next;
  779.         }
  780.     }
  781.     if (!msg) {
  782.         if (qp -> message_origin_auth_check) {
  783.             *ep = build_ext_poac (qp -> message_origin_auth_check,
  784.                           qp -> message_origin_auth_check_crit);
  785.             if (*ep)
  786.                 ep = &(*ep) -> next;
  787.         }
  788.     }
  789.     if (p1) {
  790.         if (qp -> dl_expansion_history) {
  791.             *ep = build_ext_dl (qp -> dl_expansion_history,
  792.                          qp -> dl_expansion_history_crit);
  793.             if (*ep)
  794.                 ep = &(*ep) -> next;
  795.         }
  796.     
  797.         if (qp -> trace) {
  798.             *ep = build_ext_iti (qp -> trace,
  799.                          EXT_INTERNAL_TRACE_INFORMATION_DC);
  800.             if (*ep)
  801.                 ep = &(*ep) -> next;
  802.         }
  803.     }
  804.     if ((!p1) && msg) {
  805.         if (qp -> forwarding_request != NOTOK) { 
  806.             *ep = build_ext_forw_req(qp -> forwarding_request,
  807.                                          qp -> forwarding_request_crit);
  808.             if (*ep)
  809.                 ep = &(*ep) -> next;
  810.         }
  811.         if (qp -> proof_of_submission_request) {
  812.             *ep = build_ext_posr(qp -> proof_of_submission_request,qp -> proof_of_submission_crit);
  813.             if (*ep)
  814.                 ep = &(*ep) -> next;
  815.         }
  816.     }
  817.     return ext;
  818. }
  819.  
  820.  
  821.  
  822. static struct type_MTA_Extensions *build_aext_oraa (parm, crit)
  823. char    *parm;
  824. int    crit;
  825. {
  826.     struct type_MTA_ExtensionField *ext;
  827.     struct type_MTA_Extensions *extl;
  828.     struct type_Ext_OriginatorRequestedAlternateRecipient *value;
  829.  
  830.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  831.  
  832.     ext -> type = build_ext_type (EXT_ORIGINATOR_RETURN_ADDRESS, NULLOID);
  833.  
  834.     if (crit != EXT_ORIGINATOR_RETURN_ADDRESS_DC)
  835.         ext -> criticality = build_crit (crit);
  836.     else
  837.         ext -> criticality = NULL;
  838.  
  839.     value = build_addr (parm);
  840.  
  841.     if (encode_Ext_OriginatorRequestedAlternateRecipient
  842.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  843.         adios (NULLCP, "Can't encode OriginatorRequestedAlternateRecipient value [%s]",
  844.                PY_pepy);
  845.     PP_PDUP (Ext_OriginatorRequestedAlternateRecipient,
  846.         ext -> value, "Extensions.OriginatorRequestedAlternateRecipient",
  847.         PDU_WRITE);
  848.  
  849.     free_Ext_OriginatorRequestedAlternateRecipient (value);
  850.  
  851.     wrap_up_ext (extl, ext);
  852.     return extl;
  853. }
  854.  
  855. static struct type_MTA_Extensions *build_aext_rdm (parm, crit)
  856. int    parm[AD_RDM_MAX];
  857. int    crit;
  858. {
  859.     struct type_MTA_ExtensionField *ext;
  860.     struct type_MTA_Extensions *extl;
  861.     struct type_Ext_RequestedDeliveryMethod *value, **vp;
  862.     int    i;
  863.  
  864.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  865.  
  866.     ext -> type = build_ext_type (EXT_REQUESTED_DELIVERY_METHOD, NULLOID);
  867.  
  868.     if (crit != EXT_REQUESTED_DELIVERY_METHOD_DC)
  869.         ext -> criticality = build_crit (crit);
  870.     else
  871.         ext -> criticality = NULL;
  872.  
  873.     value = NULL;
  874.     vp = &value;
  875.  
  876.     for (i = 0; i < AD_RDM_MAX && parm[i] != AD_RDM_NOTUSED; i++) {
  877.         *vp = (struct type_Ext_RequestedDeliveryMethod *)
  878.             smalloc (sizeof **vp);
  879.         (*vp) -> element_Ext_0 = parm[i];
  880.         (*vp) -> next = NULL;
  881.         vp = &(*vp) -> next;
  882.     }
  883.  
  884.     if (encode_Ext_RequestedDeliveryMethod
  885.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  886.         adios (NULLCP, "Can't encode RequestedDeliveryMethod value [%s]",
  887.                PY_pepy);
  888.     PP_PDUP (Ext_RequestedDeliveryMethod,
  889.         ext -> value, "Extensions.RequestedDeliveryMethod",
  890.         PDU_WRITE);
  891.  
  892.     free_Ext_RequestedDeliveryMethod (value);
  893.  
  894.     wrap_up_ext (extl, ext);
  895.     return extl;
  896. }
  897.  
  898. static struct type_MTA_Extensions *build_aext_pf (parm, crit)
  899. char    parm;
  900. int    crit;
  901. {
  902.     struct type_MTA_ExtensionField *ext;
  903.     struct type_MTA_Extensions *extl;
  904.     struct type_Ext_PhysicalForwardingProhibited *value;
  905.  
  906.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  907.  
  908.     ext -> type = build_ext_type (EXT_PHYSICAL_FORWARDING_PROHIBITED,
  909.                       NULLOID);
  910.  
  911.     if (crit != EXT_PHYSICAL_FORWARDING_PROHIBITED_DC)
  912.         ext -> criticality = build_crit (crit);
  913.     else
  914.         ext -> criticality = NULL;
  915.  
  916.     value = (struct type_Ext_PhysicalForwardingProhibited *)
  917.         smalloc (sizeof *value);
  918.     value -> parm = parm;
  919.  
  920.     if (encode_Ext_PhysicalForwardingProhibited
  921.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  922.         adios (NULLCP, "Can't encode PhysicalForwardingProhibited value [%s]",
  923.                PY_pepy);
  924.     PP_PDUP (Ext_PhysicalForwardingProhibited,
  925.         ext -> value, "Extend.PhysicalForwardingProhibited",
  926.         PDU_WRITE);
  927.  
  928.     free_Ext_PhysicalForwardingProhibited (value);
  929.  
  930.     wrap_up_ext (extl, ext);
  931.     return extl;
  932. }
  933.  
  934. static struct type_MTA_Extensions *build_aext_pfar (parm, crit)
  935. int    parm;
  936. int    crit;
  937. {
  938.     struct type_MTA_ExtensionField *ext;
  939.     struct type_MTA_Extensions *extl;
  940.     struct type_Ext_PhysicalForwardingAddressRequest *value;
  941.  
  942.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  943.  
  944.     ext -> type = build_ext_type (EXT_PHYSICAL_FORWARDING_ADDRESS_REQUEST, NULLOID);
  945.  
  946.     if (crit != EXT_PHYSICAL_FORWARDING_ADDRESS_REQUEST_DC)
  947.         ext -> criticality = build_crit (crit);
  948.     else
  949.         ext -> criticality = NULL;
  950.  
  951.     value = (struct type_Ext_PhysicalForwardingAddressRequest*)
  952.         smalloc (sizeof *value);
  953.  
  954.     value -> parm = parm;
  955.  
  956.     if (encode_Ext_PhysicalForwardingAddressRequest
  957.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  958.         adios (NULLCP, "Can't encode PhysicalForwardingAddressRequest value [%s]",
  959.                PY_pepy);
  960.     PP_PDUP (Ext_PhysicalForwardingAddressRequest,
  961.         ext -> value, "Extensions.PhysicalForwardingAddressRequest",
  962.         PDU_WRITE);
  963.  
  964.     free_Ext_PhysicalForwardingAddressRequest (value);
  965.  
  966.     wrap_up_ext (extl, ext);
  967.     return extl;
  968. }
  969.  
  970. static struct type_MTA_Extensions *build_aext_pdm (parm, crit)
  971. int    parm;
  972. int    crit;
  973. {
  974.     struct type_MTA_ExtensionField *ext;
  975.     struct type_MTA_Extensions *extl;
  976.     struct type_Ext_PhysicalDeliveryModes *value;
  977.     char    *p;
  978.  
  979.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  980.  
  981.     ext -> type = build_ext_type (EXT_PHYSICAL_DELIVERY_MODES, NULLOID);
  982.  
  983.     if (crit != EXT_PHYSICAL_DELIVERY_MODES_DC)
  984.         ext -> criticality = build_crit (crit);
  985.     else
  986.         ext -> criticality = NULL;
  987.  
  988.     p = int2strb (parm, 8);
  989.     value = strb2bitstr (p, 8, PE_CLASS_UNIV, PE_PRIM_BITS);
  990.     
  991.     if (encode_Ext_PhysicalDeliveryModes
  992.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  993.         adios (NULLCP, "Can't encode PhysicalDeliveryModes value [%s]",
  994.                PY_pepy);
  995.     PP_PDUP (Ext_PhysicalDeliveryModes,
  996.         ext -> value, "Extensions.PhysicalDeliveryModes",
  997.         PDU_WRITE);
  998.  
  999.     free_Ext_PhysicalDeliveryModes (value);
  1000.  
  1001.     wrap_up_ext (extl, ext);
  1002.     return extl;
  1003. }
  1004.  
  1005. static struct type_MTA_Extensions *build_aext_rmt (parm, crit)
  1006. int    parm;
  1007. int    crit;
  1008. {
  1009.     struct type_MTA_ExtensionField *ext;
  1010.     struct type_MTA_Extensions *extl;
  1011.     struct type_Ext_RegisteredMailType *value;
  1012.  
  1013.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  1014.  
  1015.     ext -> type = build_ext_type (EXT_REGISTERED_MAIL, NULLOID);
  1016.  
  1017.     if (crit != EXT_REGISTERED_MAIL_DC)
  1018.         ext -> criticality = build_crit (crit);
  1019.     else
  1020.         ext -> criticality = NULL;
  1021.  
  1022.     value = (struct type_Ext_RegisteredMailType *)
  1023.         smalloc (sizeof *value);
  1024.     value -> parm = parm;
  1025.  
  1026.     if (encode_Ext_RegisteredMailType
  1027.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  1028.         adios (NULLCP, "Can't encode RegisteredMailType value [%s]",
  1029.                PY_pepy);
  1030.     PP_PDUP (Ext_RegisteredMailType,
  1031.         ext -> value, "Extensions.RegisteredMailType",
  1032.         PDU_WRITE);
  1033.  
  1034.     free_Ext_RegisteredMailType (value);
  1035.  
  1036.     wrap_up_ext (extl, ext);
  1037.     return extl;
  1038. }
  1039.  
  1040. static struct type_MTA_Extensions *build_aext_rnfa (parm, crit)
  1041. char    *parm;
  1042. int    crit;
  1043. {
  1044.     struct type_MTA_ExtensionField *ext;
  1045.     struct type_MTA_Extensions *extl;
  1046.     struct type_Ext_RecipientNumberForAdvice *value;
  1047.  
  1048.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  1049.  
  1050.     ext -> type = build_ext_type (EXT_RECIPIENT_NUMBER_FOR_ADVICE, NULLOID);
  1051.  
  1052.     if (crit != EXT_RECIPIENT_NUMBER_FOR_ADVICE_DC)
  1053.         ext -> criticality = build_crit (crit);
  1054.     else
  1055.         ext -> criticality = NULL;
  1056.  
  1057.     value = STR2QB (parm);
  1058.  
  1059.     if (encode_Ext_RecipientNumberForAdvice
  1060.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  1061.         adios (NULLCP, "Can't encode RecipientNumberForAdvice value [%s]",
  1062.                PY_pepy);
  1063.     PP_PDUP (Ext_RecipientNumberForAdvice,
  1064.         ext -> value, "Extensions.RecipientNumberForAdvice",
  1065.         PDU_WRITE);
  1066.  
  1067.     free_Ext_RecipientNumberForAdvice (value);
  1068.  
  1069.     wrap_up_ext (extl, ext);
  1070.     return extl;
  1071. }
  1072.  
  1073. static struct type_MTA_Extensions *build_aext_pra (parm, crit)
  1074. OID    parm;
  1075. int    crit;
  1076. {
  1077.     struct type_MTA_ExtensionField *ext;
  1078.     struct type_MTA_Extensions *extl;
  1079.     struct type_Ext_PhysicalRenditionAttributes *value;
  1080.  
  1081.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  1082.  
  1083.     ext -> type = build_ext_type (EXT_PHYSICAL_RENDITION_ATTRIBUTES,
  1084.                       NULLOID);
  1085.  
  1086.     if (crit != EXT_PHYSICAL_RENDITION_ATTRIBUTES_DC)
  1087.         ext -> criticality = build_crit (crit);
  1088.     else
  1089.         ext -> criticality = NULL;
  1090.  
  1091.     value = oid_cpy (parm);
  1092.  
  1093.     if (encode_Ext_PhysicalRenditionAttributes
  1094.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  1095.         adios (NULLCP, "Can't encode PhysicalRenditionAttributes value [%s]",
  1096.                PY_pepy);
  1097.     PP_PDUP (Ext_PhysicalRenditionAttributes,
  1098.         ext -> value, "Extensions.PhysicalRenditionAttributes",
  1099.         PDU_WRITE);
  1100.  
  1101.     free_Ext_PhysicalRenditionAttributes (value);
  1102.  
  1103.     wrap_up_ext (extl, ext);
  1104.     return extl;
  1105. }
  1106.  
  1107. static struct type_MTA_Extensions *build_aext_pdrr (parm, crit)
  1108. int    parm;
  1109. int    crit;
  1110. {
  1111.     struct type_MTA_ExtensionField *ext;
  1112.     struct type_MTA_Extensions *extl;
  1113.     struct type_Ext_PhysicalDeliveryReportRequest *value;
  1114.  
  1115.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  1116.  
  1117.     ext -> type = build_ext_type (EXT_PHYSICAL_DELIVERY_REPORT_REQUEST, NULLOID);
  1118.  
  1119.     if (crit != EXT_PHYSICAL_DELIVERY_REPORT_REQUEST_DC)
  1120.         ext -> criticality = build_crit (crit);
  1121.     else
  1122.         ext -> criticality = NULL;
  1123.  
  1124.     value = (struct type_Ext_PhysicalDeliveryReportRequest *)
  1125.         smalloc (sizeof *value);
  1126.     value -> parm = parm;
  1127.  
  1128.     if (encode_Ext_PhysicalDeliveryReportRequest
  1129.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  1130.         adios (NULLCP, "Can't encode PhysicalDeliveryReportRequest value [%s]",
  1131.                PY_pepy);
  1132.     PP_PDUP (Ext_PhysicalDeliveryReportRequest,
  1133.         ext -> value, "Extensions.PhysicalDeliveryReportRequest",
  1134.         PDU_WRITE);
  1135.  
  1136.     free_Ext_PhysicalDeliveryReportRequest (value);
  1137.  
  1138.     wrap_up_ext (extl, ext);
  1139.     return extl;
  1140. }
  1141.  
  1142. static struct type_MTA_Extensions *build_aext_mt (parm, crit)
  1143. struct qbuf *parm;
  1144. int    crit;
  1145. {
  1146.     struct type_MTA_ExtensionField *ext;
  1147.     struct type_MTA_Extensions *extl;
  1148.  
  1149.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  1150.  
  1151.     ext -> type = build_ext_type (EXT_MESSAGE_TOKEN, NULLOID);
  1152.  
  1153.     if (crit != EXT_MESSAGE_TOKEN_DC)
  1154.         ext -> criticality = build_crit (crit);
  1155.     else
  1156.         ext -> criticality = NULL;
  1157.  
  1158.     ext -> value = build_ext_value (parm);
  1159.     PP_PDUP (Ext_MessageToken,
  1160.         ext -> value, "Extensions.MessageToken",
  1161.         PDU_WRITE);
  1162.  
  1163.     wrap_up_ext (extl, ext);
  1164.     return extl;
  1165. }
  1166.  
  1167. static struct type_MTA_Extensions *build_aext_cic (parm, crit)
  1168. struct qbuf    *parm;
  1169. int    crit;
  1170. {
  1171.     struct type_MTA_ExtensionField *ext;
  1172.     struct type_MTA_Extensions *extl;
  1173.  
  1174.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  1175.  
  1176.     ext -> type = build_ext_type (EXT_CONTENT_INTEGRITY_CHECK, NULLOID);
  1177.  
  1178.     if (crit != EXT_CONTENT_INTEGRITY_CHECK_DC)
  1179.         ext -> criticality = build_crit (crit);
  1180.     else
  1181.         ext -> criticality = NULL;
  1182.  
  1183.     ext -> value = build_ext_value (parm);
  1184.  
  1185.     PP_PDUP (Ext_ContentIntegrityCheck,
  1186.         ext -> value, "Extensions.ContentIntegrityCheck",
  1187.         PDU_WRITE);
  1188.  
  1189.     wrap_up_ext (extl, ext);
  1190.     return extl;
  1191. }
  1192.  
  1193. static struct type_MTA_Extensions *build_aext_podr (parm, crit)
  1194. int    parm;
  1195. int    crit;
  1196. {
  1197.     struct type_MTA_ExtensionField *ext;
  1198.     struct type_MTA_Extensions *extl;
  1199.     struct type_Ext_ProofOfDeliveryRequest *value;
  1200.  
  1201.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  1202.  
  1203.     ext -> type = build_ext_type (EXT_PROOF_OF_DELIVERY_REQUEST, NULLOID);
  1204.  
  1205.     if (crit != EXT_PROOF_OF_DELIVERY_REQUEST_DC)
  1206.         ext -> criticality = build_crit (crit);
  1207.     else
  1208.         ext -> criticality = NULL;
  1209.  
  1210.     value = (struct type_Ext_ProofOfDeliveryRequest *)
  1211.         smalloc (sizeof *value);
  1212.     value -> parm = parm;
  1213.  
  1214.     if (encode_Ext_ProofOfDeliveryRequest
  1215.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  1216.         adios (NULLCP, "Can't encode ProofOfDeliveryRequest value [%s]",
  1217.                PY_pepy);
  1218.     PP_PDUP (Ext_ProofOfDeliveryRequest,
  1219.         ext -> value, "Extensions.ProofOfDeliveryRequest",
  1220.         PDU_WRITE);
  1221.  
  1222.     free_Ext_ProofOfDeliveryRequest (value);
  1223.  
  1224.     wrap_up_ext (extl, ext);
  1225.     return extl;
  1226. }
  1227.  
  1228. static struct type_Ext_RedirectionHistory *build_redir (redir)
  1229. Redirection *redir;
  1230. {
  1231.     struct type_Ext_RedirectionHistory *rlist, **rp;
  1232.     struct type_Ext_Redirection *rd;
  1233.  
  1234.     rlist = NULL;
  1235.     rp = &rlist;
  1236.     for ( ; redir; redir = redir -> rd_next) {
  1237.         *rp = (struct type_Ext_RedirectionHistory *)
  1238.             smalloc (sizeof **rp);
  1239.         (*rp) -> next = NULL;
  1240.         (*rp) -> Redirection = rd =
  1241.             (struct type_Ext_Redirection *)
  1242.                 smalloc (sizeof *rd);
  1243.         rd -> intended__recipient__name =
  1244.             (struct type_Ext_IntendedRecipientName *)
  1245.                 smalloc (sizeof *rd -> intended__recipient__name);
  1246.         rd -> intended__recipient__name -> address =
  1247.             build_addr (redir -> rd_addr);
  1248.         rd -> intended__recipient__name -> redirection__time =
  1249.             build_time (redir -> rd_time);
  1250.  
  1251.         rd -> redirection__reason =
  1252.             (struct type_Ext_RedirectionReason *)
  1253.                 smalloc (sizeof *rd -> redirection__reason);
  1254.         rd -> redirection__reason -> parm = redir -> rd_reason;
  1255.         
  1256.     }
  1257.     return rlist;
  1258. }
  1259.  
  1260. static struct type_MTA_Extensions *build_aext_rh (parm, crit)
  1261. Redirection    *parm;
  1262. int    crit;
  1263. {
  1264.     struct type_MTA_ExtensionField *ext;
  1265.     struct type_MTA_Extensions *extl;
  1266.     struct type_Ext_RedirectionHistory *value;
  1267.  
  1268.     ext = (struct type_MTA_ExtensionField *) smalloc (sizeof *ext);
  1269.  
  1270.     ext -> type = build_ext_type (EXT_REDIRECTION_HISTORY, NULLOID);
  1271.  
  1272.     if (crit != EXT_REDIRECTION_HISTORY_DC)
  1273.         ext -> criticality = build_crit (crit);
  1274.     else
  1275.         ext -> criticality = NULL;
  1276.  
  1277.     value = build_redir (parm);
  1278.  
  1279.     if (encode_Ext_RedirectionHistory
  1280.         (&ext -> value, 1, 0, NULLCP, value) == NOTOK)
  1281.         adios (NULLCP, "Can't encode RedirectionHistory value [%s]",
  1282.                PY_pepy);
  1283.     PP_PDUP (Ext_RedirectionHistory,
  1284.         ext -> value, "Extensions.RedirectionHistory",
  1285.         PDU_WRITE);
  1286.  
  1287.     free_Ext_RedirectionHistory (value);
  1288.  
  1289.     wrap_up_ext (extl, ext);
  1290.     return extl;
  1291. }
  1292.  
  1293. struct type_MTA_Extensions *build_prf_ext (ad,p1,msg)
  1294. ADDR    *ad;
  1295. int    p1,msg; 
  1296. {
  1297.     X400_Extension *pp_ext;
  1298.     struct type_MTA_Extensions *extl, **ep;
  1299.  
  1300. #define bump(x)    if (*(x)) (x) = &(*x) -> next
  1301.     extl = NULL;
  1302.     ep = &extl;
  1303.     for (pp_ext = ad -> ad_per_recip_ext_list; pp_ext;
  1304.          pp_ext = pp_ext -> ext_next) {
  1305.         *ep = (struct type_MTA_Extensions *)
  1306.             smalloc (sizeof *ep);
  1307.         (*ep) -> next = NULL;
  1308.         (*ep) -> ExtensionField = build_extension (pp_ext);
  1309.         bump(ep);
  1310.     }
  1311.     if (ad -> ad_orig_req_alt) {
  1312.         *ep = build_aext_oraa (ad -> ad_orig_req_alt,
  1313.                        ad -> ad_orig_req_alt_crit);
  1314.         bump(ep);
  1315.     }
  1316.     if (ad -> ad_req_del[0] != AD_RDM_NOTUSED) {
  1317.         *ep = build_aext_rdm (ad -> ad_req_del,
  1318.                       ad -> ad_req_del_crit);
  1319.         bump(ep);
  1320.     }
  1321.     if (ad -> ad_phys_rendition_attribs) {
  1322.         *ep = build_aext_pra (ad -> ad_phys_rendition_attribs,
  1323.                       ad -> ad_phys_rendition_attribs_crit);
  1324.         bump(ep);
  1325.     }
  1326.     if (msg) {
  1327.         if (ad -> ad_phys_forward) {
  1328.             *ep = build_aext_pf (ad -> ad_phys_forward,
  1329.                          ad -> ad_phys_forward_crit);
  1330.             bump(ep);
  1331.         }
  1332.         if (ad -> ad_phys_fw_ad_req) {
  1333.             *ep = build_aext_pfar (ad -> ad_phys_fw_ad_req,
  1334.                            ad -> ad_phys_fw_ad_crit);
  1335.             bump(ep);
  1336.         }
  1337.         if (ad -> ad_phys_modes) {
  1338.             *ep = build_aext_pdm (ad -> ad_phys_modes,
  1339.                           ad -> ad_phys_modes_crit);
  1340.             bump(ep);
  1341.         }
  1342.  
  1343.         if (ad -> ad_reg_mail_type) {
  1344.             *ep = build_aext_rmt (ad -> ad_reg_mail_type,
  1345.                           ad -> ad_reg_mail_type_crit);
  1346.             bump (ep);
  1347.         }
  1348.         if (ad -> ad_recip_number_for_advice) {
  1349.             *ep = build_aext_rnfa (ad -> ad_recip_number_for_advice,
  1350.                            ad -> ad_recip_number_for_advice_crit);
  1351.             bump (ep);
  1352.         }
  1353.         if (ad -> ad_pd_report_request) {
  1354.             *ep = build_aext_pdrr (ad -> ad_pd_report_request,
  1355.                           ad -> ad_pd_report_request_crit);
  1356.             bump (ep);
  1357.         }
  1358.         if (ad -> ad_message_token) {
  1359.             *ep = build_aext_mt (ad -> ad_message_token,
  1360.                          ad -> ad_message_token_crit);
  1361.             bump (ep);
  1362.         }
  1363.         if (ad -> ad_content_integrity) {
  1364.             *ep = build_aext_cic (ad -> ad_content_integrity,
  1365.                           ad -> ad_content_integrity_crit);
  1366.             bump(ep);
  1367.         }
  1368.         if (ad -> ad_proof_delivery) {
  1369.             *ep = build_aext_podr (ad -> ad_proof_delivery,
  1370.                            ad -> ad_proof_delivery_crit);
  1371.             bump(ep);
  1372.         }
  1373.     }
  1374.     if (p1) {
  1375.         if (ad -> ad_redirection_history) {
  1376.             *ep = build_aext_rh (ad -> ad_redirection_history,
  1377.                          ad -> ad_redirection_history_crit);
  1378.             bump (ep);
  1379.         }
  1380.     }
  1381.     return extl;
  1382. }
  1383.